package com.xy.util;

import android.content.Context;
import android.media.AudioManager;

/**
 * Created by XuYang
 * 2023/4/28
 * Email:544066591@qq.com
 */
public class AudioUtil {

    //获取多媒体最大音量
    public static int getMediaMaxVolume(Context context) {
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        return am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    }

    //获取多媒体音量
    public static int getMediaVolume(Context context) {
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        return am.getStreamVolume(AudioManager.STREAM_MUSIC);
    }

    //设置多媒体音量
    public static void setMediaVolume(Context context, int volume) {
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        am.setStreamVolume(AudioManager.STREAM_MUSIC, volume,
                AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI);
    }
}
